//寻找建筑进驻
params ["_group", "_dis"];

//
private _unit = leader _group;
private _list_building = nearestObjects[_unit, ["House"], _dis];//nearestBuilding _unit;

if(count _list_building == 0) exitWith{};

//if(Param_Debug == 1) then{systemChat format["寻找到附近房屋可进驻:%1", _dis]};

private _units = units _group;
private _list_pos = [];
{
	_list_pos append (_x buildingPos -1);
}forEach _list_building;


private _count = (count _list_pos) min (count _units);

//if(Param_Debug == 1) then{systemChat str _count};

for ("_i") from 0 to (_count - 1) do{
	(_units select _i) doMove (_list_pos select _i);
	[_units select _i]spawn{
		waitUntil{sleep 1;unitReady _this};
		doStop _this;
	};
};

